
"""
    pyprosim - a simple prolog compiler developed to PCS2056 course (Compilers) at Poli-USP\
    Copyright (C) 2008 Rodrigo Rodrigues da Silva

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
"""

import unittest
from pycoopiler.codegen import codegen
import logging
import time

class testcodegen(unittest.TestCase):
    
    def test_funcoes(self):
        f = open('cases/test_codegen_' + time.strftime("%H_%M_%S", time.localtime()), 'w')
        cg = codegen(f)
        cg.header()
        cg.jump("0000")
        cg.jump("0001", "label1")
        cg.jzero("label1")
        cg.jneg("0002")
        cg.lval("003", "label2")
        cg.add("3")
        cg.sub("0004")
        cg.mul("0005")
        cg.div("0006")
        cg.load("0007")
        cg.save("0008")
        cg.call("0009")
        cg.ret("000A")
        cg.halt("000B")
        cg.get("000C")
        cg.put("000D")
        cg.os("000E")
        f.close()